<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        var collection = {
    "1275":{
        "album":"依然范特西",
        "artist":"周杰伦",
        "tracks":[
            "听妈妈的话",
            "千里之外"
        ]
},
    "2468":{
        "album":"西界",
        "artist":"林俊杰",
        "tracks":[
            "西界",
            "杀手"
        ]
},
    "3245":{
        "artist":"许嵩",
        "tracks":[ ]
    },
    "5439":{
        "album":"遇见"
    },

    // // 1).如果传入的value是一个空值，表示将该属性删除
    updateRecords :function (id,prop,value){
    // 2).传入的prop如果是tracks，则代表添加，其他是修改
        if(value ==undefined){
            delete collection[id][prop];
        }else{
            if(prop=="tracks"){
                collection[id][prop].push(value) ;
            }else{
                collection[id][prop] = value;

            }
        }
    }



}
collection.updateRecords("3245","mod","cc");

console.log(collection);
// 1.定义方法更新记录:
// 要求：




    </script>
</body>
</html>